<?php

class Application_Form_Projectadd extends Zend_Form {

    public function init() {
        #db value get
        $userDb = new Application_Model_Users();
        $fetchAll = $userDb->fetchAll();
        $optionsDb = new Application_Model_Options();
        $projectStatus = $optionsDb->getByName("projectStatus");
        #
        $this->setMethod("post");

        #name
        $name = new Zend_Form_Element_Text('name');
        $name->setLabel("Project Name:")
                ->setRequired()
                ->addFilter("StringTrim")
                ->setAttribs(array('class' => 'span12'));

        #external project url
        $projectLink = new Zend_Form_Element_Text('projectLink');
        $projectLink->setLabel("Enter External Project Link:")
                ->setRequired()
                ->addFilter("StringTrim")
                ->setAttribs(array('class' => 'span12'));


        #description
        $description = new Zend_Form_Element_Textarea('description');
        $description->setLabel("Proect Description")
                ->setRequired()
                ->addFilter("StringTrim")
                ->setAttribs(array('class' => 'span12', 'rows' => 10));

        #select User
        $user = new Zend_Form_Element_Select('userId');
        $user->setLabel("Select User:")
                ->setRequired()
                ->setAttribs(array('class' => 'span12'));
        foreach ($fetchAll as $userData) {
            $user->addMultiOption($userData['id'], $userData['name']);
        }

        #status
        $status = new Zend_Form_Element_Select('status');
        $status->setLabel("Select Status:")
                ->setRequired()
                ->addFilter("StringTrim")
                ->setAttribs(array('class' => 'span12'));
        $index = 0;
        foreach ($projectStatus['details'] as $value) {
            $status->addMultiOption($index, $value);
            $index++;
        }

        #id
        $id = new Zend_Form_Element_Hidden('id');
        $id->setValue(0);

        #submit
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel("Create New Project")
                ->setAttribs(array('class' => 'btn btn-success btn-large'));


        $this->addElements(array($name, $projectLink, $description, $user, $status,$id, $submit));
    }

}

